<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>广告图</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/swiper.min.css" />
		<link rel="stylesheet" type="text/css" href="fonts/iconfont/iconfont.css" />
		<style>
			html,
			body {
				position: relative;
				height: 100%;
				background: #eee;
				font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
				font-size: 14px;
				color: #000;
				margin: 0;
				padding: 0;
			}
			
			button {
				display: block;
				padding: 3px 16px;
				color: #fff;
				font-size: 14px;
				background: rgba(0, 0, 0, 0.2);
				border-radius: 20px;
				position: absolute;
				right: 15px;
				top: 10px;
				z-index: 999;
			}
			
			img {
				width: 100%;
				height: 100%;
			}
		</style>
	</head>

	<body ng-app="app" ng-controller="my_controller">
		<div>
			<button ng-if="showBtn"><span class="colorP">5S</span>&nbsp;跳过广告</button>
			<img ng-src="{{adver.img}}" />
			<input type="hidden" name="" id="" value="{{adver.url}}" />
		</div>

	</body>
	<!-- Swiper JS -->
	<script src="js/mui.min.js"></script>
	<script src="js/angular.min.js"></script>
	<script src="js/jquery.min.js"></script>
	<script src="js/apppublic.js"></script>
	<script type="text/javascript">
		function advertising() {
			var countdown = 5; //设定广告停留时间
			var timer = setInterval(function() {
				countdown--;
				$('button').html("<span class='colorP'>"+countdown+"S</span>&nbsp;跳过广告");
				if(countdown <= 0) {
					clearInterval(timer);
					window.location.href = "view/login.html";
				}
			}, 1000);
			
			//点击广告图片跳转
			$('img').on('tap',function(){
				clearInterval(timer);
				plus.nativeUI.showWaiting('加载中...');
				window.location.href = ""+$('input').val()+"";
				plus.nativeUI.closeWaiting();
			})
			
			//点击跳过广告跳转
			$('body').on('tap','button', function() {
				clearInterval(timer);				
				window.location.href = "view/login.html";
				return false;
			})

		}
		var app = angular.module("app", []);
		app.controller("my_controller", function($scope, $http) {
			$scope.initView = function() {
				plus.nativeUI.showWaiting('加载中...');
				$http({
					method: 'post',
					url: apiRoot,
					data: {
						action: 'Ad.adList',
					}
				}).then(function successCallback(response) {
					plus.nativeUI.closeWaiting();
					$scope.adver = response.data.data;
					advertising();
					$scope.showBtn = 1;
				}, function errorfunction(e) {
					plus.nativeUI.closeWaiting();
					console.log(JSON.stringify(e));
				})
			}

		})

		document.addEventListener("plusready", function() {
			var first = plus.storage.getItem('first');
			if (!first){
				setTimeout(function(){
					plus.webview.currentWebview().close();
				}, 1000); 
				plus.webview.create('splash.html','splash.html').show('pop-in');
				return;
			}
			$('img').css({ 'width': $(window).innerWidth(), 'height': $(window).innerHeight() });
			appElement = document.querySelector('[ng-controller=my_controller]');
			$scope = angular.element(appElement).scope();
			$scope.initView();
			$scope.$apply();
		})
	</script>

</html>